
global data_folder "W:\intimate\data"
global log_folder "W:\intimate\dofiles\logs"
global output_folder "W:\intimate\results_revision"

use "W:\intimate\data\allwomen_data_clean_withDV", clear 
keep if dv_couple==1

// no. reports
g couple_N_group = dv_couple_events
replace couple_N_group = 6 if dv_couple_events>6
lab define cg 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6+"
lab values couple_N_group cg
hist couple_N_group, discrete fcolor(blue%50) lcolor(blue) ///
		graphregion(color(white)) xtitle("DV Police Reports per Couple") ///
		xlabel(1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 6 "6+")
graph export "$output_folder\event_dist.pdf", replace

keep shnro sphnro0 year_start_cohab
ren shnro ao_shnro
ren sphnro0 shnro 
save "W:\intimate\data\dv_couple_ids", replace 

use "W:\intimate\data\dvonly_all.dta", clear


merge m:1 shnro ao_shnro using "W:\intimate\data\dv_couple_ids"
keep if _merge==3
drop _merge

// Crime type distribution 
preserve 
gen Crimes="eeOthers"

replace Crimes="aaAssault" if crimecode6=="210501"
replace Crimes="bbPetty assault" if crimecode6=="210701"
replace Crimes="ccMenace" if crimecode6=="250701"

encode Crimes, gen(crime_code)
hist crime_code, discrete fcolor(blue%50) lcolor(blue) ///
		graphregion(color(white)) xtitle("Crime Types") ///
		xlabel(1 "Assault" 2 "Petty Assault" 3 "Menace" 4 "Others")
graph export "$output_folder\crimetype_dist.pdf", replace
restore 

bys shnro ao_shnro : egen first_dv = min(year_event)
g time_diff = first_dv - year_start_cohab


hist time_diff if time_diff>=0, discrete fcolor(blue%50) lcolor(blue) ///
		graphregion(color(white)) xtitle("Time from Cohabitation to First DV Report") 
graph export "$output_folder\time_to_report_dist.pdf", replace




